﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DanhMuc_tttt : System.Web.UI.Page
{
    _dbDataContext _db = new _dbDataContext();
    public List<MemberShip_ASP.ItemMaDoanVien> listmadoanvien = new List<MemberShip_ASP.ItemMaDoanVien>();
    SecurityLib.Sec_AES _se = new SecurityLib.Sec_AES();
    protected void Page_Load(object sender, EventArgs e)
    {
        MemberShip_ASP.ItemMaDoanVien item;
        string[] strst = Session["ListMaDoanVien_Print"].ToString().Split('!');
        for (int i = 0; i < strst.Length - 1; i++)
        {
            item = new MemberShip_ASP.ItemMaDoanVien();
            item.MaDoanVien = strst[i];
            listmadoanvien.Add(item);
        }
        string st = Session["TenDonVi_Print"].ToString();
        lblcosodoan.Text = st;
        lblngay.Text = st + ", Ngày " + DateTime.Now.Day.ToString() + " tháng " + DateTime.Now.Month.ToString() + " năm " + DateTime.Now.Year.ToString();
        lbldanhsach.Text = "DANH SÁCH ĐOÀN VIÊN " + st.ToUpper();
        try
        {
            Response.Clear();
            Response.AddHeader("content-disposition", "attachment; filename=FileName.xls");
            Response.Charset = "";
            Response.ContentType = "application/vnd.xls";
            System.IO.StringWriter stringWrite = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
            grid_Detail.RenderControl(htmlWrite);
            Response.Write(stringWrite.ToString());
            Response.End();
            Response.Redirect("javascript:window.close()");
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('" + ex.Message + "')</script>");
        }
    }
    public tblDoanVien GetDoanVien(string madoanvien)
    {
        return _db.tblDoanViens.Single(r => r.MaDonVien.Trim() == madoanvien.Trim());
    }
}